﻿using PRO.DbProvider;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using PRO.Common;
using PRO.Entity;
using PRO.ORM;

namespace PRO.Data.SqlServer
{
    public partial class DataProvider : IDataProvider
    {
        public bool IsExistUser(string username)
        {
            string sql = "SELECT count(id) FROM Pro_User where username=@username";
            DbParameter[] prams = {
									 DbHelper.MakeInParam("@username",(DbType)SqlDbType.NVarChar,50,username)
								   };
            if (DbHelper.ExecuteScalar(CommandType.Text, sql, prams).ToString().ToInt(0) > 0)
                return true;
            else
                return false;
        }
        public int AddUser(UserInfo ui)
        {
            return ui.Insert();
        }
        public DataTable GetUserInfo(string username)
        { 
            string sql = "SELECT id,nick,username,pwd,regdate FROM Pro_User where username=@username";
            DbParameter[] prams = {
									 DbHelper.MakeInParam("@username",(DbType)SqlDbType.NVarChar,50,username)
								   };
            return DbHelper.ExecuteDataset(CommandType.Text, sql, prams).Tables[0];
        }
    }
}
